<?php 
/*
* 自定义功能函数
*/
if(!defined('EMLOG_ROOT')) {exit('error!');} 
?>
<?php
//分类名称地址
function logssort($logsid){
	global $CACHE; 
	$log_cache_sort = $CACHE->readCache('logsort');
	?>
	<?php if(!empty($log_cache_sort[$logsid])):?>
	<a href="<?php echo Url::sort($log_cache_sort[$logsid]['id']); ?>" title="<?php echo $log_cache_sort[$logsid]['name'];?>" target="_blank"><?php echo $log_cache_sort[$logsid]['name'];?></a>
	<?php endif;?>
	<?php }?>
<?php 
function idown_url()
{
	$log_content =  ob_get_clean();
	$log_content = preg_replace_callback("|\[idown](.*?)\[/idown]|is",'idown_show',$log_content);
	if(Option::get('isgzipenable') == 'y' && function_exists('ob_gzhandler')){ob_start('ob_gzhandler');}else{ob_start();}
	echo $log_content;	
}
addAction('index_footer','idown_url');

function idown_show($match){
	$content = $match[1];
	$return = '<div class="down_heading"><span></span></div>';
	$return .= '<div class="downline" id="idown_url"><a class="inline" href="#inline_content">
	<img src="'.TEMPLATE_URL.'ibox/images/down.png" title="点击查看下载地址" alt="下载地址"><span><br/>点击查看<br/>下载地址</span></a>';
	$return .= '</div><div class="downad">

<script type="text/javascript"><!--
google_ad_client = "ca-pub-6188876196041059";
/* 爱博客首页468x60 */
google_ad_slot = "1127121333";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

	</div>';
	$return .= '<div class="down_heading"><span></span></div>';
	$return .= '<div class="download"><div id="inline_content">
	
<br/>
<div class="down_heading"><span></span></div>
'.$content.'</div></div>';
	return $return;
}
function imgshow()
{
	$log_content =  ob_get_clean();
	$pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png|swf)('|\")(.*?)>(.*?)<\/a>/i";
	$replacement = '<a$1href=$2$3.$4$5 class="group3"$6>$7</a>';
	$log_content = preg_replace($pattern, $replacement, $log_content);
	if(Option::get('isgzipenable') == 'y' && function_exists('ob_gzhandler')){ob_start('ob_gzhandler');}else{ob_start();}
	echo $log_content;	
}
addAction('index_footer','imgshow');

function divshow()
{
	$log_content =  ob_get_clean();
	$pattern = "/<div([^<>]*)>([^<>]*)<\/div>/i";
	$replacement = '<p$1>$2</p>';
	$log_content = preg_replace($pattern, $replacement, $log_content);
	if(Option::get('isgzipenable') == 'y' && function_exists('ob_gzhandler')){ob_start('ob_gzhandler');}else{ob_start();}
	echo $log_content;	
}
addAction('index_footer','divshow');
?>
<?php 
function images_excerpt($row){
    preg_match_all("|<img[^>]+src=\"([^>\"]+)\"?[^>]*>|is", $row['excerpt'], $img);
	$excerpt_img = !empty($img[1]) ? $img[1][0] : '';
	return $excerpt_img;
}
function images_content($row){
	preg_match_all("|<img[^>]+src=\"([^>\"]+)\"?[^>]*>|is", $row['content'], $img);
	$content_img = !empty($img[1]) ? $img[1][0] : '';
	return $content_img;
}
function images_src($row){
	if(images_excerpt($row)):
		{ echo images_excerpt($row);
	} elseif(images_content($row)):
		{ echo images_content($row);} 
	else:{ echo ''.temp_images_src(rand(1,50)).'';
	} endif;
}
function logs_thumb($row,$w,$h){
	echo ''.TEMPLATE_URL.'thumb/thumb.php?src=';
	echo ''.images_src($row).'&amp;zc=3&amp;w='.$w.'&amp;h='.$h.'&amp;q=95';
}
?>
<?php
function nohtml($content){
  $content = preg_replace("/<a[^>]*>/i",'', $content);   
  $content = preg_replace("/<\/a>/i", '', $content);    
  $content = preg_replace("/<div[^>]*>/i",'', $content);   
  $content = preg_replace("/<\/div>/i",'', $content);
  $content = preg_replace("/<font[^>]*>/i",'', $content);   
  $content = preg_replace("/<\/font>/i",'', $content);
  $content = preg_replace("/<p[^>]*>/i",'', $content);   
  $content = preg_replace("/<\/p>/i",'', $content);
  $content = preg_replace("/<span[^>]*>/i",'', $content);   
  $content = preg_replace("/<\/span>/i",'', $content);
  $content = preg_replace("/<\?xml[^>]*>/i",'', $content);
  $content = preg_replace("/<\/\?xml>/i",'', $content);
  $content = preg_replace("/<o:p[^>]*>/i",'', $content);
  $content = preg_replace("/<\/o:p>/i",'', $content);
  $content = preg_replace("/<u[^>]*>/i",'', $content);
  $content = preg_replace("/<\/u>/i",'', $content);
  $content = preg_replace("/<b[^>]*>/i",'', $content);
  $content = preg_replace("/<\/b>/i",'', $content); 
  $content = preg_replace("/<meta[^>]*>/i",'', $content);
  $content = preg_replace("/<\/meta>/i",'', $content);
  $content = preg_replace("/<!--[^>]*-->/i",'', $content);//注释内容  
  $content = preg_replace("/<p[^>]*-->/i",'', $content);//注释内容       
  $content = preg_replace("/style=.+?['|\"]/i",'',$content);//去除样式   
  $content = preg_replace("/class=.+?['|\"]/i",'',$content);//去除样式   
  $content = preg_replace("/id=.+?['|\"]/i",'',$content);//去除样式      
  $content = preg_replace("/lang=.+?['|\"]/i",'',$content);//去除样式       
  $content = preg_replace("/width=.+?['|\"]/i",'',$content);//去除样式    
  $content = preg_replace("/height=.+?['|\"]/i",'',$content);//去除样式    
  $content = preg_replace("/border=.+?['|\"]/i",'',$content);//去除样式    
  $content = preg_replace("/face=.+?['|\"]/i",'',$content);//去除样式 
  $content = preg_replace("/<img([^>]+?)>/i",'',$content);
  $content = preg_replace("/<embed([^>]+?)>/i",'',$content);
  $content = preg_replace("/face=.+?['|\"]/",'',$content);
  $content=str_replace( "&nbsp;","",$content);
  return $content;
}?>
<?php
//预备缩略图
function temp_images_src($thumb_num){
	if($thumb_num == '1'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821513025THX.jpg';
	}if($thumb_num == '2'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821513086THX.jpg';
	}if($thumb_num == '3'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821513390THX.jpg';
	}if($thumb_num == '4'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821513070THX.jpg';
	}if($thumb_num == '5'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821505022THX.jpg';
	}if($thumb_num == '6'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821505036THX.jpg';
	}if($thumb_num == '7'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821505159THX.jpg';
	}if($thumb_num == '8'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/65855331201302182150535THX.jpg';
	}if($thumb_num == '9'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821510176THX.jpg';
	}if($thumb_num == '10'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821505387THX.jpg';
	}if($thumb_num == '11'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821505820THX.jpg';
	}if($thumb_num == '12'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821485384THX.jpg';
	}if($thumb_num == '13'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821485470THX.jpg';
	}if($thumb_num == '14'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821485429THX.jpg';
	}if($thumb_num == '15'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/21/658553312013021821490180THX.jpg';
	}if($thumb_num == '16'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821490272THX.jpg';
	}if($thumb_num == '17'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821485586THX.jpg';
	}if($thumb_num == '18'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/21/658553312013021821490298THX.jpg';
	}if($thumb_num == '19'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130217/22/6585533120130217224417010.jpg';
	}if($thumb_num == '20'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130217/22/6585533120130217224015079.jpg';
	}if($thumb_num == '21'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823410098THX.jpg';
	}if($thumb_num == '22'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/65855331201302182341002THX.jpg';
	}if($thumb_num == '23'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/65855331201302182341216THX.jpg';
	}if($thumb_num == '24'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823412121THX.jpg';
	}if($thumb_num == '25'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823451562THX.jpg';
	}if($thumb_num == '26'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/65855331201302182345166THX.jpg';
	}if($thumb_num == '27'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823453270THX.jpg';
	}if($thumb_num == '28'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823453213THX.jpg';
	}if($thumb_num == '29'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/65855331201302182345491THX.jpg';
	}if($thumb_num == '30'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823454959THX.jpg';
	}if($thumb_num == '31'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823462275THX.jpg';
	}if($thumb_num == '32'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823463592THX.jpg';
	}if($thumb_num == '33'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823465077THX.jpg';
	}if($thumb_num == '34'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823470239THX.jpg';
	}if($thumb_num == '35'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823471762THX.jpg';
	}if($thumb_num == '36'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823482448THX.jpg';
	}if($thumb_num == '37'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823482413THX.jpg';
	}if($thumb_num == '38'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823483760THX.jpg';
	}if($thumb_num == '39'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823483788THX.jpg';
	}if($thumb_num == '40'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/65855331201302182348497THX.jpg';
	}if($thumb_num == '41'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823485059THX.jpg';
	}if($thumb_num == '42'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823490291THX.jpg';
	}if($thumb_num == '43'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823490156THX.jpg';
	}if($thumb_num == '44'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823491360THX.jpg';
	}if($thumb_num == '45'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823491596THX.jpg';
	}if($thumb_num == '46'){
		echo'http://img14.poco.cn/mypoco/myphoto/20130218/23/658553312013021823492478THX.jpg';
	}if($thumb_num == '47'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823495941THX.jpg';
	}if($thumb_num == '48'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130218/23/658553312013021823495981THX.jpg';
	}if($thumb_num == '49'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130219/22/65855331201302192215565THX.jpg';
	}if($thumb_num == '50'){
		echo'http://img13.poco.cn/mypoco/myphoto/20130219/22/658553312013021922184088THX.jpg';
	}
}?>